const Router = require('koa-router')
const AreaController = require('../controllers/area.controller')
const jwt = require('../middlewares/jwt.middleware')
const isRole = require('../middlewares/role.middleware')

const router = new Router()
const areaController = new AreaController()
router.prefix('/api/areas')

router.get('/', jwt, areaController.findAll)

router.post('/', jwt, isRole(['admin']), areaController.addOne)

router.get('/:id', jwt, areaController.findOne)

router.patch('/:id', jwt, isRole(['admin']), areaController.updateOne)

router.delete('/:id', jwt, isRole(['admin']), areaController.deleteOne)

module.exports = router